<?php
/**
 * Created by PhpStorm.
 * User: 小蛮哼哼哼
 * Email: 243194993@qq.com
 * Date: 2022/3/22
 * Time: 11:11
 * motto: 现在的努力是为了小时候吹过的牛逼！
 */

namespace app\api\controller\v1;

use app\api\model\WeixinUser;
use app\common\lib\Show;
use app\common\lib\Status;

class User extends Base
{
    public function updateByUserInfo()
    {
        $nickName = $this->request->param('nickName', '', 'trim');
        $avatarUrl = $this->request->param('avatarUrl', '', 'trim');
        $openid = $this->request->param('openid', '', 'trim');
        if (empty($openid)) {
            return Show::json_show(Status::mini_error, "用户错误");
        }
        try {
            $result = (new WeixinUser())->updateByUserInfo([
                "nickName" => $nickName,
                "avatarUrl" => $avatarUrl,
                "openid" => $openid
            ]);
        } catch (\Exception $e) {
            return Show::json_show(Status::mini_error, $e->getMessage());
        }
        return Show::json_show(Status::mini_normal, "ok", $result);
    }
}